package com.wjc.lib

import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

/**
 * ClassName: com.wjc.lib
 * Description:
 * JcChen on 2021.04.13.15:37
 */
object Example {
    var delegate: String by MyByDelegate()

    @JvmStatic
    fun main(args: Array<String>) {
        delegate = "ddddddd"
        println(delegate)
    }

    class MyByDelegate {
        operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
            return "$thisRef, thank you for delegating '${property.name}' to me!"
        }

        operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
            println("$value has been assigned to '${property.name}' in $thisRef.")
        }
    }
}





